package com.wn.servlet.demo02;

import java.io.UnsupportedEncodingException;

/**
 * @author yellow Docter
 * @date 2022 -06-29
 * @desc
 *
 * 01  字符串乱码
 *
 */
public class Demo01 {

    public static void main(String[] args) throws Exception {

        // 01  编码不统一乱码
        String str = "中了500W美元";
        byte[] bytes = str.getBytes("utf-8");

        String s = new String(bytes,"utf-8");
        System.out.println("s = " + s);

        // 02  数据丢失乱码
        String s1 = new String(bytes, 0, bytes.length);
        System.out.println("s1 = " + s1);

    }

}
